﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>狼途汽车门店管理平台-登录</title>
    <link rel="stylesheet" href="/static/js/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="/static/js/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/js/Ionicons/css/ionicons.min.css">
    <link rel="stylesheet" href="/static/js/adminlte/css/AdminLTE.min.css">
    <link rel="stylesheet" href="/static/js/adminlte/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="/static/js/adminlte/css/fonts.googleapis.com.css">

    <script src="/static/js/jquery/jquery.min.js"></script>
    <script src="/static/js/bootstrap/js/bootstrap.js"></script>
    <script src="/static/js/adminlte/js/adminlte.min.js"></script>

    <link rel="stylesheet" href="/static/js/plugins/sweetalert2/sweetalert2.min.css">
    <script src="/static/js/plugins/sweetalert2/sweetalert2.min.js"></script>

    <!--  表单使用ajax方式提交  -->
    <script src="/static/js/plugins/jquery-form/jquery.form.js"></script>




</head>
<body class="hold-transition login-page">
<div class="login-box">
    <div class="login-logo">
        <a href="http://www.wolfcode.cn"><b>狼途</b>汽车门店管理平台</a>
    </div>
    <div class="login-box-body">
        <p class="login-box-msg">请输入账号密码</p>

        <form method="post" id="loginForm" action="/userLogin">
            <div class="form-group has-feedback">
                <input type="text" name="username" class="form-control" placeholder="请输入账号"  value="">
                <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input type="password" name="password" class="form-control" placeholder="请输入密码"  value="">
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            </div>
            <div class="row">
                <div class="col-xs-4">
                    <button type="submit" class="btn btn-primary btn-block btn-flat submitBtn">登录</button>
                </div>
            </div>
        </form>

        <script>
            /*$('.submitBtn').click(function () {
                $.post('/userLogin',$('#loginForm').serialize() ,function (data) {
                    if (data.success){
                        location.href='/employee/list';
                    }else {
                        Swal.fire({
                            icon: 'error',
                            title: data.msg,
                            text: '账号或密码错误!',
                            footer: '<a href>为什么会出现错误呢?</a>'
                        });
                    }
                });
            })*/

            //jquery-form插件提供ajaxForm方法，把表单升级为ajax的方式提交，不会马上提交，
            $("#loginForm").ajaxForm(function (data) {
                console.log(data);
                if(data.success){
                    window.location.href = "/employee/list";
                }else{
                    Swal.fire(
                        '登录失败',
                        data.msg,
                        'error'
                    )
                }
            })
        </script>

    </div>
</div>




</body>
</html>
